<?php
    
    session_start();

    $usuario = $_POST['login'];
    $senha = $_POST['senha'];
    
    include("php/conecta.php");
    
    $sql = "SELECT * FROM usuario WHERE login='$usuario' and senha='$senha'";
    $result = mysql_query($sql);
    $count = mysql_num_rows($result);
    
    if ($count == '1') {
        $_SESSION['login'] = $usuario;
        $_SESSION['senha'] = $senha;
        mysql_close();
        header("location:principal.php");
    }else{
        unset ($_SESSION['login']);
        unset ($_SESSION['senha']);
        mysql_close();
        header("location:erro.php");
    }

?>